package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsCouponHistory;
import com.mall.mapper.SmsCouponHistoryMapper;
import com.mall.service.SmsCouponHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsCouponHistoryServiceImpl extends ServiceImpl<SmsCouponHistoryMapper, SmsCouponHistory> implements SmsCouponHistoryService {

    @Resource
    private SmsCouponHistoryMapper smsCouponHistoryMapper;

    @Override
    public SmsCouponHistory getById(Integer id) {
        return smsCouponHistoryMapper.selectById(id);
    }

    @Override
    public List<SmsCouponHistory> getAll() {
        return smsCouponHistoryMapper.selectList(null);
    }

    @Override
    public List<SmsCouponHistory> getByMemberId(Long id) {
        return smsCouponHistoryMapper.getByMemberId(id);
    }



    @Override
    public boolean deleteById(Integer id) {
        return smsCouponHistoryMapper.deleteById(id) > 0;
    }

    @Override
    public SmsCouponHistory getByIds(Long id, Long id1) {
        return smsCouponHistoryMapper.getByIds(id,id1);
    }

    @Override
    public boolean save(SmsCouponHistory smsCouponHistory) {
        if(smsCouponHistory.getId() == null)
        {
            return smsCouponHistoryMapper.insert(smsCouponHistory) > 0;
        }else{
            return  smsCouponHistoryMapper.updateById(smsCouponHistory) > 0;
        }
    }

    @Override
    public boolean setUsed(Long couponId, Long memberId) {
        return smsCouponHistoryMapper.setUsed(couponId, memberId);
    }
}
